package com.ang.juc.n1;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //FutureTask构建参数是一个Callable类型的对象，实现了Callable接口
        FutureTask<Integer> futureTask = new FutureTask<>(()->{
            System.out.println("FutureTask启动..."+Thread.currentThread().getName());
            Thread.sleep(1000);
            return 100;
        });

        Thread thread1 = new Thread(futureTask, "thread1");
        thread1.start();

        System.out.println(futureTask.get());
    }
}
